package org.emcode.sample.appleguice.server;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

/**
 * Represents a visitor counter in the datastore and stores the number of shards.
 *
 * @author j.s@google.com (Jeff Scudder)
 * @author stuartmoffatt@gmail.com
 */
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class VisitorCounter {
  @PrimaryKey
  @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
  private Long id;

  @Persistent
  private String counterName;

  @Persistent
  private Integer numShards;

  public VisitorCounter(String counterName) {
    this.counterName = counterName;
    this.numShards = new Integer(0);
  }

  public VisitorCounter(String counterName, Integer numShards) {
    this.counterName = counterName;
    this.numShards = numShards;
  }

  public Long getId() {
    return id;
  }

  public String getCounterName() {
    return counterName;
  }

  public Integer getShardCount() {
    return numShards;
  }

  public void setShardCount(int count) {
    this.numShards = new Integer(count);
  }
}

